from media.lib.views import FileUploadFormMixin
from project.views.lib import (
    HTMXProjectSubCreateFormViewNoPK,
    HTMXProjectSubUpdateFormViewNoPK,
    ProjectSubIndexRedirectView,
    ProjectSubAuditDetailViewNoPK,
    ProjectSubAuditFormPostAPIViewNoPK,
    template_path,
)

from .. import forms, models


class FinishIndexView(ProjectSubIndexRedirectView):
    model = models.Finish
    detail_view_name = "project:finish/detail"
    create_view_name = "project:finish/create"

class FinishCreateView(
    FileUploadFormMixin,
    HTMXProjectSubCreateFormViewNoPK
):
    form_class = forms.FinishForm
    template_name = template_path("detail_form_base.html")
    create_view_name = "project:finish/create"
    detail_view_name = "project:finish/detail"

class FinishDetailView(ProjectSubAuditDetailViewNoPK):
    model = models.Finish
    form_class = forms.FinishForm
    template_name = template_path("finish/detail.html")
    audit_permission = "user.can_manage_projects"
    audit_viewname = "project:finish/audit"


class FinishUpdateView(
    FileUploadFormMixin,
    HTMXProjectSubUpdateFormViewNoPK
):
    model = models.Finish
    form_class = forms.FinishForm
    update_view_name = "project:finish/update"
    detail_view_name = "project:finish/detail"

    
class FinishAuditFormPostAPIView(ProjectSubAuditFormPostAPIViewNoPK):
    model = models.Finish
    

